home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / doc / libnet-dbus-perl / examples / example-service-no-introspect.pl < prev    next >
Encoding:
Perl Script  |  2008-02-20  |  1014 b   |  54 lines

  1. #!/usr/bin/perl
  2.  
  3. use warnings;
  4. use strict;
  5.  
  6. use Carp qw(confess cluck);
  7. use Net::DBus;
  8. use Net::DBus::Service;
  9. use Net::DBus::Reactor;
  10.  
  11. #...  continued at botom
  12.  
  13.  
  14. package SomeObject;
  15.  
  16. use base qw(Net::DBus::Object);
  17.  
  18. sub new {
  19.     my $class = shift;
  20.     my $service = shift;
  21.     my $self = $class->SUPER::new($service, "/SomeObject");
  22.     bless $self, $class;
  23.     
  24.     return $self;
  25. }
  26.  
  27. sub HelloWorld {
  28.     my $self = shift;
  29.     my $message = shift;
  30.     print "Do hello world\n";
  31.     print $message, "\n";
  32.     return ["Hello", " from example-service.pl"];
  33. }
  34.  
  35. sub GetDict {
  36.     my $self = shift;
  37.     print "Do get dict\n";
  38.     return {"first" => "Hello Dict", "second" => " from example-service.py"};
  39. }
  40.  
  41. sub GetTuple {
  42.     my $self = shift;
  43.     print "Do get tuple\n";
  44.     return ["Hello Tuple", " from example-service.py"];
  45. }
  46.  
  47. package main;
  48.  
  49. my $bus = Net::DBus->session();
  50. my $service = $bus->export_service("org.designfu.SampleService");
  51. my $object = SomeObject->new($service);
  52.  
  53. Net::DBus::Reactor->main->run();
  54.